package com.cyzy.controller;

import com.cyzy.dto.Result;
import com.cyzy.service.WeatherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 天气接口控制器
 */
@RestController
@RequestMapping("/weather")
public class WeatherController {
    
    @Autowired
    private WeatherService weatherService;
    
    @GetMapping("/info")
    public Result getWeatherInfo() {
        try {
            String weatherData = weatherService.getWeatherInfo();
            return Result.ok().data("weather", weatherData).message("获取天气信息成功");
        } catch (Exception e) {
            e.printStackTrace();
            return Result.error().message("获取天气信息失败：" + e.getMessage());
        }
    }
} 